package com.swp.oa.util;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
public class MySQLBackUpByListener implements ServletContextListener {

//	private Timer timer = null;
	@Override
	public void contextDestroyed(ServletContextEvent event) {
		System.out.println("销毁计时器了");
//		timer.cancel();
	}

	@Override
	public void contextInitialized(ServletContextEvent event) {
		System.out.println("启动计时器了");
//		timer = new Timer(true); 
//        //设置执行时间
//        Calendar calendar = Calendar.getInstance();
//        int year = calendar.get(Calendar.YEAR);
//        int month = calendar.get(Calendar.MONTH);
//        int day = calendar.get(Calendar.DAY_OF_MONTH);//每天
//        //定制每天的21:09:00执行，
//        calendar.set(year, month, day, MySQLDatabaseBackUpOption.getBackUpHour(), 
//        							   MySQLDatabaseBackUpOption.getBackUpMinute(), 
//        							   MySQLDatabaseBackUpOption.getBackUpSecond());
//        Date date = calendar.getTime();
//        //每天的date时刻执行task, 仅执行一次
//        timer.schedule(new MySQLBackUpTimerTask(), date);
	}

}
